package com.vvv.designpattern.iterator;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

/**
 * @author vvv
 * @date 2023-11-27 12 06
 * discription 迭代器模式：
 * EsSqlQuery为具体容器角色，用于生成具体迭代器
 */
@Data
@JsonIgnoreProperties
public class EsSqlQuery implements EsSqlQueryInterface<EsQueryIterator> {
    // sql 语句
    private String query;
    // 查询条数
    private Long fetchSize;

    private String cursor;

    public EsSqlQuery(String query, Long fetchSize) {
        this.query = query;
        this.fetchSize = fetchSize;
    }


    public EsSqlQuery(String cursor) {
        this.cursor = cursor;
    }

    @Override
    public EsQueryIterator iterator() {
        return new EsQueryIterator(query, fetchSize);
    }
}
